<?php

class Logger
{
	protected $ruta;
	protected $error;
	private $id;

	public function __construct($ruta,$error)
	{
		$this->error = str_replace("'","",$error);
		$this->ruta = str_replace("'","",$ruta);
		try 
		{
			$db = new PDO("mysql:host=mejorcalidadprecio.com;dbname=calprec", "user" , "passwd" );//Esta conex nunca falla xD
			$sql = "INSERT INTO log (ruta,error) VALUES ('$this->ruta','$this->error')";
			$resp = $db->exec($sql);
			if( $resp==1 )
			{
				$sql = "SELECT ID FROM log ORDER BY ID DESC LIMIT 0,1";
				$resp = $db->query($sql);
				foreach( $resp as $row )
					print "<br>Logeado correctamente con el codigo {$row['ID']}<br>";
			}
			else
				print "Ha habido un error logeando?? $sql";
		}
		catch( PDOException $e )
		{
			print "La conex debe ir FATAL, no se ha conectado el logger!!!";
			print $e->getMessage();
		}
	}
}

?>